/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.dao.impl;

import com.ivanbiz.dao.KasAwalDAO;
import com.ivanbiz.helper.HibernateUtil;
import com.ivanbiz.helper.UserSession;
import com.ivanbiz.model.KasAwal;
import com.ivanbiz.model.KasAwalHistory;
import com.ivanbiz.model.User;
import java.util.Date;
import org.hibernate.Session;

/**
 *
 * @author City_Z
 */
public class KasAwalDAOImpl extends GenericDAOImpl implements KasAwalDAO{

 
    public void saveKasAwalAndHistory(Session session,String noPO, double amount) throws Exception{           
            User user = UserSession.getUser();
            KasAwal kasAwal = (KasAwal)session.load(KasAwal.class, Long.parseLong("1"));
            kasAwal.setKasAwal(kasAwal.getKasAwal()+amount);
            KasAwalHistory kasHistory = new KasAwalHistory();
            kasHistory.setNoPO(noPO);
            kasHistory.setTambahKas(amount);
            kasHistory.setTanggalTambahKas(new Date());
            kasHistory.setUser(user);
            //session.update(kasAwal);
            session.save(kasHistory);      
    }
    
}
